/***
 * Brian Hession -- February 15, 2013
 * 
 * Animation
 *
 * Changelog
 * Date				Changes
 * 2/15/2013		Initial version
 *
 */

#include "animation.h"

Animation::Animation() {
	numClips = 0;
	length = 0;
	duration = 0;
	images = NULL;
	clip = 0;
	frame = 0;
	timestamp = 0;
}

Animation::Animation( SDL_Rect* images, int length, int numClips, int duration ) {
	this->numClips = numClips;
	this->length = length;
	this->duration = duration;
	this->images = images;
	clip = 0;
	frame = 0;
}

void Animation::setImages( SDL_Rect* images ) {
	this->images = images;
}

void Animation::setNumClips( int numClips ) {
	this->numClips = numClips;
}

void Animation::setLength( int length ) {
	this->length = length;
}

void Animation::setDuration( int duration ) {
	this->duration = duration;
}

void Animation::setClip( int clip ) {
	if( clip >= numClips ) clip = 0;
	this->clip = clip;
	frame = clip*length;
}

void Animation::setTimestamp( int time ) {
	timestamp = time;
}

int Animation::getNumClips() {
	return numClips;
}

int Animation::getLength() {
	return length;
}

int Animation::getDuration() {
	return duration;
}

int Animation::getClip() {
	return clip;
}

SDL_Rect* Animation::getImage() {
	return &images[frame];
}

int Animation::getTimestamp() {
	return timestamp;
}

void Animation::step() {
	++frame;
	if( frame >= clip*length + length )
		frame = clip*length;
}

void Animation::reset() {
	frame = clip;
}

